/*
 * Copyright 2006 Robert Burrell Donkin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 
package rat.license.standard;

import java.util.regex.Pattern;

import rat.license.ILicense;
import rat.license.ILicenseMatcher;

/**
 * JavaDocs are generated and so no license is required.
 * It is useful to not these separately.
 */
public class JavaDocLicenseNotRequired extends BaseLicense implements ILicenseMatcher, 
IStandardLicense {

    private static final String JAVADOC_REGEX_DEFN = ".*Generated by javadoc.*";
    
    private static final Pattern JAVADOC_REGEX = Pattern.compile(JAVADOC_REGEX_DEFN);
    
    public JavaDocLicenseNotRequired() {
        super("JDOC", "Generated JavaDocs", 
                "JavaDocs are generated and so license header is optional", "", true);
    }

    public ILicense match(String line) {
        ILicense result = null;
        if (JAVADOC_REGEX.matcher(line).matches()) {
            result = this;
        }
        return result;
    }

    public void reset() {
        // stateless
    }

    public void accept(IStandardLicenseVisitor visitor) {
        visitor.visit(this);
    }
}
